package binaryTree;

public class Test {
    public static void main(String[] args) {
        BinaryTree tree = new BinaryTree();
        BinaryTree.TreeNode baseNode = tree.createTree();
        //前序遍历：A->B->D->E->H->C->F->G
        tree.preorderTraversal(baseNode);
        System.out.println();
        //中序遍历：D->B->E->H->A->F->C->G
        tree.inorderTraversal(baseNode);
        System.out.println();
        //后序遍历：D->H->E->B->F->G->C->A
        tree.postorderTraversal(baseNode);
        System.out.println();
        System.out.println("总节点个数为："+tree.size(baseNode));
        System.out.println();
        System.out.println("叶子节点个数为："+tree.leafNode(baseNode));
        System.out.println();
        System.out.println("第k层节点个数为："+tree.getKLevelNodeCount(baseNode, 1));
        System.out.println();
        System.out.println("树的高度为："+tree.getHeight(baseNode));
        System.out.println();
        BinaryTree.TreeNode ret = tree.find(baseNode,'H');
        if(ret!=null) {
            System.out.println(ret.val);
        } else {
            System.out.println("没有找到！");
        }
    }
}
